<template>
  <div>
    <Chart :cdata="cdata"/>
  </div>
</template>

<script>
import Chart from './chart.vue';
import {getProportionStage, queryAllProcessEmissionOrigin} from "@/api/carbon-manage/data";

export default {
  data() {
    return {
      cdata: {
        xData: ["data1", "data2", "data3", "data4", "data5", "data6"],
        seriesData: [
          {value: 10, name: "data1"},
          {value: 5, name: "data2"},
          {value: 15, name: "data3"},
          {value: 25, name: "data4"},
          {value: 20, name: "data5"},
          {value: 35, name: "data6"}
        ]
      }
    }
  },
  components: {
    Chart,
  },
  mounted() {
    this.loadData()
  },
  methods: {
    loadData() {
      queryAllProcessEmissionOrigin(new Date().getFullYear()).then(res => {
        let xData = res.data.map(item => {
          return item.processName;
        })
        let seriesData = res.data.map(item => {
          return {value: item.carbonEmission, name: item.processName};
        })

        this.cdata = {
          xData: xData,
          seriesData: seriesData
        }
      })
    },
  }
}
</script>

<style lang="scss" scoped>
</style>
